package com.miracle.main.module.mvp.ui.activity;

import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.miracle.basemvp.base.BaseActivity;
import com.miracle.basemvp.di.component.AppComponent;
import com.miracle.common.adapter.SingleSelectAdapter;
import com.miracle.common.bean.User.CheckBean;
import com.miracle.common.view.BaseDialogProvider;
import com.miracle.main.R;
import com.miracle.main.R2;
import com.miracle.main.module.di.component.DaggerAddSecretComponent;
import com.miracle.main.module.di.module.AddSecretModule;
import com.miracle.main.module.mvp.contract.AddSecretContract;
import com.miracle.main.module.mvp.presenter.AddSecretPresenter;
import com.trello.rxlifecycle2.LifecycleProvider;
import com.trello.rxlifecycle2.android.ActivityEvent;

import java.util.List;

import javax.inject.Inject;

import butterknife.OnClick;

/**
 * com.miracle.main.module.mvp.ui.activity
 * (c)2018 AIR Times Inc. All rights reserved.
 *
 *
 * @author WangJQ
 * @version 1.0
 * @date 2018/7/7 10:29
 * @see com.miracle.main.module.mvp.ui.activity
 */
public class AddSecretActivity extends BaseActivity<AddSecretPresenter> implements AddSecretContract.View {

    @Inject
    List<CheckBean> mList;
    @Inject
    SingleSelectAdapter mAdapter;

    AlertDialog mAddPicMethodDialog;
    BaseDialogProvider dialogProvider;


    @Override
    public int setLayoutId(@Nullable Bundle bundle) {
        return R.layout.cloud_activity_add_secret;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {

    }

    @Override
    public void setDaggerComponent(AppComponent appComponent) {
        DaggerAddSecretComponent
                .builder()
                .appComponent(appComponent)
                .addSecretModule(new AddSecretModule(this))
                .build()
                .inject(this);
    }

    @Override
    public void onRequest(LifecycleProvider<ActivityEvent> lifecycleProvider) {

    }

    private void showMoodPopup() {
        RecyclerView rcv = null;
        if (mAddPicMethodDialog == null) {
            dialogProvider = new BaseDialogProvider(this);
            mAddPicMethodDialog = dialogProvider.createDialog(R.layout
                    .dialog_single_select);
            rcv = dialogProvider.getView(R.id.rv);
            rcv.setLayoutManager(new LinearLayoutManager(this));
            rcv.setAdapter(mAdapter);
        }
        mAdapter.setSingleClickListener(new SingleSelectAdapter.OnSingleItemClick() {
            @Override
            public void onSingleClick(int position) {
                mAddPicMethodDialog.dismiss();
            }
        });

        mAddPicMethodDialog.show();
    }

    @OnClick({R2.id.iv_back, R2.id.tv_submit, R2.id.ll_mood})
    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == R.id.iv_back) {

        }

        if (id == R.id.ll_mood) {
            showMoodPopup();
        }

        if (id == R.id.tv_submit) {

        }
    }

    @Override
    public void showData(Object o) {

    }
}
